package com.foreknow.demo5Exercise2;

import java.util.Scanner;

public class Rule {

    public Rule() {

    }

    private int time;

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }
    Person p = new Person();
    Computer c = new Computer();

    public static void welcome() {
        System.out.println("-----------欢迎进入游戏世界-------------");
        System.out.println("     ****************************      ");
        System.out.println("     **********猜拳开始***********      ");
        System.out.println("     ****************************      ");
        System.out.println("出拳规则：1.剪刀  2.石头 3.布");
    }
    public void name() {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入你的姓名：");
         p.setName(input.next());

    }

    int ps;
    int ns;
    public int lbrule() {
        int chuquan = p.person();
        int random = c.liuBei();
        if (chuquan > random || (chuquan == 1 && random == 3)) {
            System.out.println("结果：恭喜，你赢了！");
            ++ps;
            return ps;
        }else if(chuquan == random){
            System.out.println("结果：平局！");
            return ps;
        }else {
            System.out.println("结果：遗憾，你输了...");
            ++ns;
            return ns;
        }
    }

    public int sqrule() {
        int chuquan = p.person();
        int random = c.sunQuan();
        if (chuquan > random || (chuquan == 1 && random == 3)) {
            System.out.println("结果：恭喜，你赢了！");
            ++ps;
            return ps;
        }else if(chuquan == random){
            System.out.println("结果：平局！");
            return ps;
        }else {
            System.out.println("结果：遗憾，你输了...");
            ++ns;
            return ns;
        }
    }

    public int ccrule() {
        int chuquan = p.person();
        int random = c.caoCao();
        if (chuquan > random || (chuquan == 1 && random == 3)) {
            System.out.println("结果：恭喜，你赢了！");
            ++ps;
            return ps;
        }else if(chuquan == random){
            System.out.println("结果：平局！");
            return ps;
        }else {
            System.out.println("结果：遗憾，你输了...");
            ++ns;
            return ns;
        }
    }

    public void choosenpc(int a) {
        switch (a) {
            case 1:
                c.setNpc("刘备");
                System.out.println(p.getName() + " VS 刘备 对战");
                int result1 = lbrule();
                break;
            case 2:
                c.setNpc("孙权");
                System.out.println(p.getName() + " VS 孙权 对战");
                int result2 = sqrule();
                break;
            case 3:
                c.setNpc("曹操");
                System.out.println(p.getName() + " VS 曹操 对战");
                int result3 = ccrule();
                break;
        }
    }

    public void show() {


        System.out.println("--------------------------------------");
        System.out.println(c.getNpc() + " VS "+ p.getName());
        System.out.println("对战次数：" + getTime() + "\n");
        System.out.println("姓名      得分");
        System.out.println(p.getName() + "    " + ps);
        System.out.println(c.getNpc() + "    " + ns);
        if (p.getScore() > c.getScore()) {
            System.out.println("结果：恭喜恭喜！");
        }else if (p.getScore() == c.getScore()) {
            System.out.println("结果：平局......");
        }else {
            System.out.println("结果：失败了 :( ");
        }
        System.out.println("--------------------------------------");
    }

}
